home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cnews009 / rse.c < prev   
C/C++ Source or Header  |  1988-07-16  |  682b  |  30 lines

  1. /* RSE.C -- a program to redirect standard error
  2.  *
  3.  * Written by Scott R. Houck
  4.  *
  5.  * This program will redirect standard error to standard output
  6. so
  7.  * that a program's standard error output can be sent to a file
  8.  * using the redirection symbols '>' or '>>' on the command line.
  9.  *
  10.  * The syntax is:  RSE program [arguments]
  11.  */
  12.  
  13. #include <stdio.h>
  14. #include <io.h>
  15. #include <process.h>
  16.  
  17. int main(argc, argv)
  18. int argc;
  19. char **argv;
  20. {
  21.      if (argv < 2)
  22.           {
  23.       fprintf(stderr, "Usage: RSE program [arguments]\n");
  24.           exit(1);
  25.           }
  26.      ++argv;
  27.      dup2(fileno(stdout), fileno(stderr));
  28.      return spawnvp(P_WAIT, *argv, argv);
  29. }
  30.